// ml:run = $bin < input
// ml:opt = 0
// ml:ccf += -g
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>

int const opt[4][2] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
int const maxn = 200;
char map[maxn][maxn];
bool vis[maxn][maxn];
int n, m, k;

struct pos { int x, y; };
struct lake { int area; pos p; };

bool operator<(lake const& a, lake const& b)
{
    return a.area < b.area;
}

bool inrange(pos p)
{
    return (1 <= p.x && p.x <= n) && (1 <= p.y && p.y <= m);
}

void fillup(pos p)
{
    std::queue<pos> q;
    q.push(p);
    while (!q.empty()) {
        auto now = q.front(); q.pop();
        map[now.x][now.y] = '*';
        for (int t = 0; t < 4; t++) {
            pos tmp = now;
            tmp.x += opt[t][0];
            tmp.y += opt[t][1];
            if (!inrange({tmp.x, tmp.y})) continue;
            if (map[tmp.x][tmp.y] == '*' || vis[tmp.x][tmp.y]) continue;
            vis[tmp.x][tmp.y] = true;
            q.push(tmp);
        }
    }
}

std::vector<lake> v;

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin >> n >> m >> k;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) std::cin >> map[i][j];

    int tot = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            if (vis[i][j] || map[i][j] == '*') continue;
            std::queue<pos> q;
            q.push({i, j});
            bool lake = true;
            int count = 0;
            while (!q.empty()) {
                auto now = q.front(); q.pop();
                vis[now.x][now.y] = true;
                count++;
                for (int t = 0; t < 4; t++) {
                    pos tmp = now;
                    tmp.x += opt[t][0];
                    tmp.y += opt[t][1];
                    if (!inrange({tmp.x, tmp.y})) {
                        lake = false;
                        continue;
                    }
                    if (map[tmp.x][tmp.y] == '*' || vis[tmp.x][tmp.y]) continue;
                    vis[tmp.x][tmp.y] = true;
                    q.push(tmp);
                }
            }
            if (!lake) continue;
            tot++;
            v.push_back({count, {i, j}});
        }
    std::sort(v.begin(), v.end());

    int ans = 0;
    std::memset(vis, 0, sizeof(vis));
    for (int i = 0; i < tot - k; i++) {
        ans += v[i].area;
        fillup(v[i].p);
    }
    std::cout << ans << "\n";
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) std::cout << map[i][j];
        std::cout << "\n";
    }
}

